import time
from selenium import webdriver
from selenium.webdriver import Keys,ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

driver1 = webdriver.Edge()
driver1.get("https://ebank.xacbank.com/XAEIBankDemo/page/login/login.html?t=1679974008665/")
time.sleep(2)
ac = ActionChains(driver1)
driver1.implicitly_wait(5)
a = driver1.find_element(By.ID, "account")
a.send_keys("123456")
a2 = (By.ID, "login")
a3 = WebDriverWait(driver1, 5, 0.5).until(expected_conditions.element_to_be_clickable(a2))
a3.click()
a4 = (By.ID,"fw-gen-10009-closable")
a5 = WebDriverWait(driver1, 5, 0.5).until(expected_conditions.element_to_be_clickable(a4))
a5.click()
a6 = (By.XPATH,"//*[@id='1']/div/div")
a7 = WebDriverWait(driver1, 5, 0.5).until(expected_conditions.element_to_be_clickable(a6))
a7.click()
a8 = (By.XPATH,"//*[@id='fw-gen-10005-body']/ul[4]/li[2]/a")
a9 = WebDriverWait(driver1, 5, 0.5).until(expected_conditions.element_to_be_clickable(a8))
a9.click()
# 设置某个付款账户
a10 = ("id", "fw-gen-10007-body")
a11 = WebDriverWait(driver1, 5, 0.5).until(expected_conditions.element_to_be_clickable(a10))
driver1.switch_to.frame(a11)
a12 = (By.XPATH, "//*[@id='payAccount']/option[3]")
a13 = WebDriverWait(driver1, 5, 0.5).until(expected_conditions.element_to_be_clickable(a12))
a13.click()

# 选择收款人，从里面选择赵云、马超
a14=(By.XPATH,'//*[@id="form1"]/div/table/tbody/tr[5]/td/div/span[1]')
a15=WebDriverWait(driver1,5,0.5).until(expected_conditions.element_to_be_clickable(a14))
a15.click()
driver1.switch_to.default_content()
a20 = ("id", "fw-gen-10011-iframe")
a21 = WebDriverWait(driver1, 5, 0.5).until(expected_conditions.element_to_be_clickable(a20))
driver1.switch_to.frame(a21)
a16=(By.XPATH,'//*[@id="fw-gen-10001-tbody"]/tr[2]/td[1]/label')
a17=WebDriverWait(driver1,5,0.5).until(expected_conditions.element_to_be_clickable(a16))
a17.click()
a18=(By.XPATH,'//*[@id="fw-gen-10001-tbody"]/tr[3]/td[1]/label')
a19=WebDriverWait(driver1,5,0.5).until(expected_conditions.element_to_be_clickable(a18))
a19.click()
time.sleep(1)

driver1.switch_to.parent_frame()
time.sleep(1)

a23 = driver1.find_element(By.CLASS_NAME,"btn.btn-primary")
a23.click()
a35=(By.ID,"fw-gen-10007-body")
a36=WebDriverWait(driver1,5,0.5).until(expected_conditions.element_to_be_clickable(a35))
driver1.switch_to.frame(a36)
a24=(By.NAME,"TRAN_AMT")
a25=WebDriverWait(driver1,5,0.5).until(expected_conditions.element_to_be_clickable(a24))
a25.send_keys("1000")
a26=(By.XPATH,"/html/body/div/table[2]/tbody/tr[2]/td[4]/input")
a27=WebDriverWait(driver1,5,0.5).until(expected_conditions.element_to_be_clickable(a26))
a27.send_keys("2000")
a28=(By.ID,'next_btn')
a29=WebDriverWait(driver1,5,0.5).until(expected_conditions.element_to_be_clickable(a28))
a29.click()
# driver1.switch_to.parent_frame()
a40=(By.ID,'batchTempName')
a41=WebDriverWait(driver1,5,0.5).until(expected_conditions.element_to_be_clickable(a40))
a41.send_keys("123")
a30=(By.ID,'submit_btn')
a31=WebDriverWait(driver1,5,0.5).until(expected_conditions.element_to_be_clickable(a30))
a31.click()
time.sleep(10)
timestr = time.strftime("%Y-%m-%d_%H-%M-%S",time.localtime())
driver1.get_screenshot_as_file(f"d:\\xianyinhang{timestr}.png")
time.sleep(3)
driver1.quit()
# 设置收款人的转账金额分别为1000、2000
# 点击下一步
# 点击提交